
<div class="x_panel">
  <div class="x_content" style="display: block;">
    <!--表格主体内容-->
    <div class="row-fluid">
      <form action="/order/shipping.html" method="get">
        <label class="control-label">订单号</label>
        <input type="text" class="form-control-new" name="form[order_no]" value="{if isset($query.order_no)}{$query.order_no}{/if}">
        <label class="control-label">商品号</label>
        <input type="text" class="form-control-new" name="form[goods_id]" value="{if isset($query.goods_id)}{$query.goods_id}{/if}">
        <label class="control-label">商品名称</label>
        <input type="text" class="form-control-new" name="form[goods_name]" value="{if isset($query.goods_name)}{$query.goods_name}{/if}">
        <label class="control-label">商品类型</label>
        <select  class="form-control-new" name="form[category_id]" >
          <option {if !isset($query.category_id) || $query.category_id==0}selected="selected"{/if} value="0">全部</option>
          {foreach $category AS $value}
          <option {if isset($query.category_id) && $query.category_id==$value.category_id}selected="selected"{/if} value="{$value.category_id}">{$value.category_name}</option>
          {/foreach}
        </select>

        <label class="control-label">下单时间</label>
        <input type="text"  name="form[order_start_time]" value="{if isset($query.order_start_time)}{$query.order_start_time}{/if}" placeholder="开始时间" id="J_dh_start" class="form-control-new" >
        <input type="text"  name="form[order_end_time]" value="{if isset($query.order_end_time)}{$query.order_end_time}{/if}" placeholder="结束时间" id="J_dh_end" class="form-control-new" >
        <label class="control-label">支付时间</label>
        <input type="text"  name="form[pay_start_time]" value="{if isset($query.pay_start_time)}{$query.pay_start_time}{/if}" placeholder="开始时间" id="J_dh_start1" class="form-control-new" >
        <input type="text"  name="form[pay_end_time]" value="{if isset($query.pay_end_time)}{$query.pay_end_time}{/if}" placeholder="结束时间" id="J_dh_end1" class="form-control-new" >

        <button name="submit" type="submit" class="btn btn-primary" value="search">查询</button>
        <button name="submit" value="export" type="submit" class="btn btn-primary" >导出</button>
      </form>
        <br>
      <form action="/order/shipping.html" method="post" enctype="multipart/form-data" onsubmit="return check()">
        <input type="file" name="shipping_file" id="file">
        <button name="submit" value="import" type="submit" class="btn btn-primary" >导入</button>
      </form>


    </div>
    <br>
    <div class="cont">
      <table class="table table-bordered table-striped">
        <thead>
        <tr>
          <th width="100px">订单号</th>
          <th>商品名称</th>
          <th>商品编号</th>
          <th>商品数量</th>
          <th>商品单价</th>
          <th>订单金额</th>
          <th>商品分类</th>
          <th>订单时间</th>
          <th>收件人手机号</th>
          <th>收件人姓名</th>
          <th>收件人地址</th>
          <th>身份证号</th>
          <th>订单来源</th>
          <th>用户留言</th>
          <th>寄送状态</th>
          <th>快递公司</th>
          <th>快递单号</th>
          <th>寄件时间</th>
          <th>备注</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $order.lists as $orderitem}
        <tr>
          <td>{$orderitem.order_no}</td>
          <td>{$orderitem.goods_name}</td>
          <td>{$orderitem.goods_id}</td>
          <td>{$orderitem.goods_num}</td>
          <td>{$orderitem.real_price}</td>
          <td>{$orderitem.order_amount}</td>
          <td>{$orderitem.category_name}</td>
          <td>{$orderitem.order_time}</td>
          <td>{$orderitem.shipping_mobile}</td>
          <td>{$orderitem.consignee}</td>
          <td>{$orderitem.shipping_address}</td>
          <td>{$orderitem.id_card}</td>
          <td>{$orderitem.mall_id}/{$orderitem.mall_name}</td>
          <td>{$orderitem.user_remark}</td>
          <td>
            {if $orderitem.shipping_status==0}待寄送{elseif $orderitem.shipping_status==1}已寄送{/if}
          </td>
          <td>{$orderitem.express_company}</td>
          <td>{$orderitem.express_no}</td>
          <td>{$orderitem.shipping_time}</td>
          <td>{$orderitem.shipping_remark}</td>

        <td>
          <div class="x_content">
            <button class="shipping-order btn btn-primary btn-xs" data-order="{$orderitem.order_id}" data-goods-name="{$orderitem.goods_name}" data-goods-num="{$orderitem.goods_num}" data-consignee="{$orderitem.consignee}" data-express-company="{$orderitem.express_company}"  data-express-no="{$orderitem.express_no}" data-shipping-remark="{$orderitem.shipping_remark}"> 操作</button>
          </div>
        </td>
        </tr>
        {/foreach}
        </tbody>
      </table>
      <!--分页-->
      {Yii::$app->view->render('/com/pager.php',['pager'=>$order.pager])}

    </div>
  </div>
</div>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="detail-modal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header" style="border:none">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myModalLabel">修改寄件信息</h4>
      </div>
      <div class="modal-body">
        <div class="loaders">
          <div class="ball-spin-fade-loader">
            商品名称：<span id="goodsname"></span>&nbsp; &nbsp; &nbsp; &nbsp; 商品数量：<span id="goodsnum"></span>&nbsp;&nbsp;&nbsp;&nbsp;收件人：<span id="consignee"></span>
            <br>
            快递公司：<b style="color:red">*</b><input required="required" id="express_company" type="text" value="" />
            <br>
            快递单号：<b style="color:red">*</b><input required="required" id="express_no" type="text" value="" />
            <br>
            备注：<textarea id="shipping_remark"></textarea>
          </div>
        </div>
        <div id="modal-dyn"></div>
      </div>
      <div class="modal-footer" style="border:none;">
        <button id="shippingorder" type="button" class="copy btn btn-secondary" data="">提交</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript" src="{$theme}/libs/js/datepicker/bootstrap-datetimepicker.min.js"></script>

<script>
    $(".shipping-order").click(function () {
        $('#shippingorder').attr('data',$(this).attr('data-order'));
        $('#goodsname').text($(this).attr('data-goods-name'));
        $('#goodsnum').text($(this).attr('data-goods-num'));
        $('#express_company').val($(this).attr('data-express-company'));
        $('#express_no').val($(this).attr('data-express-no'));
        $('#shipping_remark').val($(this).attr('data-shipping-remark'));
        $('#detail-modal').modal('show');
    })

    $("#shippingorder").click(function () {
        var order_id = $(this).attr('data');
        var express_company = $('#express_company').val();
        var express_no = $('#express_no').val();
        if(!express_company){
            alert('请填写配送快递公司');
            return false;
        }
        if(!express_no){
            alert('请填写配送快递单号');
            return false;
        }
        var shipping_remark = $('#shipping_remark').val();
        var url = "{['order/shipping-order']|U}";
        $.post(url, 'order_id='+order_id+'&express_company='+express_company+'&express_no='+express_no+'&shipping_remark='+shipping_remark, function (data) {
            window.location.reload();
        },'json');
        $('#detail-modal').modal('hide');
    })

    var startDate = $('#J_dh_start').datetimepicker({
        format: "yyyy-MM-dd",
        autoclose: true,
        todayBtn: true,
        minView: 2,
    })

    var endDate = $('#J_dh_end').datetimepicker({
        format: "yyyy-MM-dd",
        autoclose: true,
        todayBtn: true,
        minView: 2,
    })

    var startDate = $('#J_dh_start1').datetimepicker({
        format: "yyyy-MM-dd",
        autoclose: true,
        todayBtn: true,
        minView: 2,
    })

    var endDate = $('#J_dh_end1').datetimepicker({
        format: "yyyy-MM-dd",
        autoclose: true,
        todayBtn: true,
        minView: 2,
    })

    function check() {
        if($('#file').val().length){
            return true;
        }else{
            alert("请选择上传文件");
            return false;
        }
    }
</script>
